/**
 * Created by archer on 16/4/14.
 */
$(function(){
	MerchantsApp.loadGrid();
});

var MerchantsApp = function(){
    return {
        loadGrid:function(){
        	gui.widgets.BootStrap.loadGrid({
                gridSelector:"#grid-table",
                pagerSelector:"#grid-pager",
                postData:{
                	name:function(){
                		return $.trim($("#name").val());
                	},
                },
                jsonReader : {
                    root: "data.rows",
                    records: "data.total",
                    repeatitems : false,
                    total: function (obj) {
                        return  Math.ceil(obj.data.total /jQuery("#grid-table").getGridParam("rowNum"));
                    }
                } ,
                datatype: 'json',
                url:$('#APP_ROOT_PATH').val() + 'merchants/page_unActive',
                colNames:['公司名称','手机号','公众号名称','门店数','代理数','到期时间','操作'],
                colModel:[
                    {name:'name',index:'name', width:60,sortable:false},
                    {name:'phone',index:'phone', width:60,sortable:false},
                    {name:'wxName',index:'wxName', width:60,sortable:false},
                    {name:'shopNum',index:'shopNum', width:50,sortable:false},
                    {name:'totalNum',index:'totalNum', width:50,sortable:false},
                    {name:'gmtValidate',index:'gmtValidate', width:100,sortable:false},
                    {name:'',index:'', width:100,sortable:false,formatter:function(cellvalue,options,rowObject){
                    	var html = "";
                    	//html += "<a href='#' onclick='MerchantsApp.active("+rowObject.shopId+","+rowObject.id+")'>激活</a>|";
                    	return html;
                    }},
                ],
                caption: "未激活商家信息",
                rowList:[10,20,30],
                prmNames:{
                    page:"pageNum",
                    rows:"pageSize",
                    sort: "sortField",
                    order: "sortOrder",
                    search:"_search"
                }
            });
        },
        search:function(){
        	jQuery("#grid-table").jqGrid('setGridParam',{page:1}).trigger("reloadGrid");
        },
        
    }
}();